package com.anxin.act.task.complete.impl;

import com.anxin.act.task.cmd.SequentialAndParallelCountersignAddcmd;
import com.anxin.act.task.complete.TaskComplete;
import com.anxin.act.task.dao.ActTaskDao;
import com.anxin.act.task.service.JumpTaskService;
import com.anxin.act.task.vo.TaskVo;
import com.anxin.act.utils.ActTaskUtils;
import com.anxin.common.utils.StringUtils;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.RuntimeServiceImpl;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.task.Task;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 正常提交待办
 * @author: liuxiangyu
 * @date: 2020/4/26 16:28
 */
@Service
public class ActTaskCompleteImpl extends TaskComplete {

    @Autowired
    private JumpTaskService jumpTaskService;


    /**
     * 提交流程
     * @param taskVo
     */
    public String complete(TaskVo taskVo){


        // 保存审批意见
        super.addComment(taskVo);

        // 提交任务
        super.completeTask(taskVo);

        // 如果流程驳回以后如果提交方式是流程正常审批，则调用下AA跳的方法
        if (StringUtils.isBlank(taskVo.getRejectedCompleteType()) || "normal".equals(taskVo.getRejectedCompleteType())){
            jumpTaskService.jumpTask(taskVo.getActId(),taskVo.getId());
        }


        return taskVo.getId();

    }


}
